import React, {useState, useEffect} from "react";
import {request} from "@/src/service";

export default function useSearchAll<T>(api, search_info: any = {}) {
  const [data, setData] = useState<T[]>([]);

  useEffect(() => {
    // 自执行函数
    (async () => {
      try {
        const {result, status} = await request({
          api,
          data: {
            search_info: JSON.stringify(search_info)
          },
          flag: "customer-wechat",
        });
        status === 'ok' && setData(result.data_list)
      } catch (err) {
        console.log("err--------->>>", err);
      } finally {
      }
    })();
  }, []);

  return data
}
